<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>status_detail</title>
    <link rel="stylesheet" href="http://unpkg.com/layui@2.6.8/dist/css/layui.css">
    <style type="text/css">
#format-json {
  pre {
    outline: 1px solid #ccc;
    padding: 5px;
    .json-string {
      color: #c62628;
    }
    .json-number, .json-boolean {
      color: #1f1bcc;
    }
    .json-null {
      color: #818181;
    }
    .json-key {
      color: #861d8f;
    }
  }
}
    </style>
</head>

<script src="http://unpkg.com/layui@2.6.8/dist/layui.js"></script>

<body>
    <table class="layui-table" lay-even lay-skin="row">
        <colgroup>
            <col width="50">
            <col>
            <col>
            <col>
            <col>
            <col>
            <col>
            <col>
            <col>
        </colgroup>
        <thead>
            <tr>
                <th>运行id</th>
                <th>昵称</th>
                <th>题号</th>
                <th>状态</th>
                <th>内存(KB)</th>
                <th>时间(MS)</th>
                <th>语言</th>
                <th>代码长度</th>
                <th>提交时间</th>
            </tr> 
        </thead>
        <tbody>
            <tr>
                <td>{{ .status.Runid }}</td>
                <td>{{ .status.Username }}</td>
                <td>{{ .status.ProblemId }}</td>
                <td>{{ .status.Result }}</td>
                <td>{{ .status.UseMemory }}</td>
                <td>{{ .status.UseTime }}</td>
                <td>{{ .status.Language }}</td>
                <td>{{ .status.Length }}</td>
                <td>{{ .status.SubmitTime }}</td>
            </tr>
        </tbody>
    </table>
    <h3>通过样例:{{ .status.Pass }}/{{ .status.Total }}</h3>
    <div class="layui-card">
        <div class="layui-card-header">src</div>
        <div class="layui-card-body">
            <pre>{{ .status.Src }}</pre>
        </div>
    </div>
    {{ if ne .status.Err "" }}
    <div class="layui-card">
        <div class="layui-card-header">error</div>
        <div class="layui-card-body">
            <pre>{{ .status.Err }}</pre>
        </div>
    </div>
    {{ end }}
    {{ if ne .first_wrong_input "" }}
    <div class="layui-card">
        <div class="layui-card-header">输入样例</div>
        <div class="layui-card-body">
            <pre>{{ .first_wrong_input }}</pre>
        </div>
    </div>
    {{ end }}
    {{ if ne .first_wrong_output "" }}
    <div class="layui-card">
        <div class="layui-card-header">用户输出结果</div>
        <div class="layui-card-body">
            <pre>{{ .first_wrong_output }}</pre>
        </div>
    </div>
    {{ end }}
    {{ if ne .first_wrong_stdout "" }}
    <div class="layui-card">
        <div class="layui-card-header">标准输出结果</div>
        <div class="layui-card-body">
            <pre>{{ .first_wrong_stdout }}</pre>
        </div>
    </div>
    {{ end }}
    <table class="layui-table" lay-even lay-skin="row">
        <colgroup>
            <col width="50">
            <col>
            <col>
        </colgroup>
        <thead>
            <tr>
                <th>时间(MS)</th>
                <th>内存(KB)</th>
                <th>状态</th>
            </tr> 
        </thead>
        <tbody>
            {{ range $i, $result := .result_list}}
            <tr>
                <td>{{ $result.Time }}</td>
                <td>{{ $result.Memory }}</td>
                <td>{{ $result.Result }}</td>
            </tr>
                {{ if ne $result.Result "RUN_OK" }}
                    {{ if lt $i (len $.output_list) }}
                    <tr>
                        <td>output</td>
                        <td>{{ index $.output_list $i }}</td>
                    </tr>
                    {{ end }}
                    {{ if lt $i (len $.stdout_list) }}
                    <tr>
                        <td>stdout</td>
                        <td>{{ index $.stdout_list $i }}</td>
                    </tr>
                    {{ end }}
                {{ end }}
            {{ end }}   
        </tbody>
    </table>

<script>
    function syntaxHighlight(json) {
        if (typeof json !== 'string') {
          json = JSON.stringify(json, undefined, 2)
        } else {
          json = JSON.stringify(JSON.parse(json), undefined, 2)
        }
        json = json.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
        return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,
          function (match) {
            let cls = 'json-number'
            if (/^"/.test(match)) {
              if (/:$/.test(match)) {
                cls = 'json-key'
              } else {
                cls = 'json-string'
              }
            } else if (/true|false/.test(match)) {
              cls = 'json-boolean'
            } else if (/null/.test(match)) {
              cls = 'null'
            }
            return '<span class="' + cls + '">' + match + '</span>'
          })
      }
</script>
    <pre style="display:none;" id="recv_data">{{ .status.RecvData }}</pre>

    <div class="layui-card">
        <div class="layui-card-header">后台返回数据</div>
        <div class="layui-card-body">
            <div id="format-json">
                <pre id="display-recv-data"></pre>
            </div>
        </div>
    </div>
<script>
    var jsonObj = JSON.parse(document.getElementById("recv_data").innerText);
    jsonObj.data = JSON.parse(jsonObj.data)
    document.getElementById("display-recv-data").innerHTML = syntaxHighlight(jsonObj);
</script>
</body>

</html>